# File parser for the quake configuration files

require 'pp'
require 'q3_func'

print_help if ARGV[0].nil?
	
argv = get_charac(ARGV[0])
case argv[0]
	when'-list'
		parse_characs( open_file, 'list' )
	when '-charac'
		charac = argv[1]
		print_help if charac.nil? 	#=> oops no charac given
		print_error 'This is not a valid characteristic.' unless (parse_characs open_file ).include? charac

		files = parse_bots 	# => bot_files contains all the files with the bot configurations

		bot_groups = Array.new
		
		files.each do
			|file|
			bot_groups.push bot_pool( file )
		end

		#everything is all nice and ordered, now lets get all the values for each pool
		
		values = Array.new

		bot_groups.each do
			|pool|
			pool_values = Array.new
			pool_average = 0
			pool.each do
				|bot|
				pool_values.push parse_bot_value( bot, charac )
			end

			pool_values.each do
				|value|
				pool_average += value.to_f
			end
			average = pool_average / pool_values.length
			values.push average 
		end
		
		generate_graph( values, charac )

	else
		print_help
end

